]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
signalTracker: Don't try to create a new SignalTracker for disconnecting
authorSebastian Keller <skeller@gnome.org>
Mon, 29 Aug 2022 02:19:28 +0000 (04:19 +0200)
committerMarge Bot <marge-bot@gnome.org>
Sat, 3 Sep 2022 15:11:46 +0000 (15:11 +0000)
After the next commit, when some classes, such as PopupMenuManager try
to disconnect via a destroy handler, the SignalTracker might have
already been destroyed, so trying to get it from the SignalManager will
cause it to create a new one, which will then try to connect to the
destroy signal of the already destroyed object.

This could for example be triggered by changing backgrounds.

Fix this by not doing anything in disconnectObject if there is no
SignalTracker for that object.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2466>

js/misc/signalTracker.js

index 1c3f4f9df4d17b53ceed4d7aa56886be0a0da7ca..c72abd265e294677a4af070e2873ae833d833c7c 100644 (file)
@@ -57,6 +57,14 @@ class SignalManager {
         }
         return signalTracker;
     }
+
+    /**
+     * @param {Object} obj - object to get signal tracker for
+     * @returns {?SignalTracker} - the signal tracker for object if it exists
+     */
+    maybeGetSignalTracker(obj) {
+        return this._signalTrackers.get(obj) ?? null;
+    }
 }
 
 class SignalTracker {
@@ -225,7 +233,7 @@ function connectObject(thisObj, ...args) {
  * @returns {void}
  */
 function disconnectObject(thisObj, obj) {
-    SignalManager.getDefault().getSignalTracker(thisObj).untrack(obj);
+    SignalManager.getDefault().maybeGetSignalTracker(thisObj)?.untrack(obj);
 }
 
 /**